< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03030206.xhp

(section: timevalue) (bookmark: bm_id3149670)
TimeValue function

TimeValue 関数

TimeValue Function [Runtime]
TimeValue 関数 [実行時](hd_id3149670.1)

Calculates a serial time value from the specified hour, minute, and second - parameters passed as strings - that represents the time in a single numeric value. This value can be used to calculate the difference between times.
文字列として指定された時、分、秒の値を基に、該当する時刻を示す 1 つの数値 (シリアル値) を返します。こうして変換された数値は、2 つの時刻間の時間計算などに利用できます。(par_id3153361.2)

(/section: timevalue)

Syntax:
構文:(hd_id3154138.3)

TimeValue (Text As String)
TimeValue (Text As String)(par_id3156282.4)

Return value:
戻り値:(hd_id3153969.5)

Date
日付(par_id3156424.6)

Parameters:
パラメータ:(hd_id3145172.7)

Text: Any string expression that contains the time that you want to calculate in the format "HH:MM:SS".
Text: 「HH:MM:SS」の形式で指定した、変換する時刻データを示す文字列表式。(par_id3145786.8)

Use the TimeValue function to convert any time into a single value, so that you can calculate time differences.
この関数は、任意の時刻を 1 つの数値として変換するもので、こうした得られる数値は時刻間の時間計算などに利用できます。(par_id3152578.9)

This TimeValue function returns the type Variant with VarType 7 (Date), and stores this value internally as a double-precision number between 0 and 0.9999999999.
この TimeValue 関数 の返す値は、バリアント型の VarType 7 (Date) であり、内部的には0から 0.9999999999 の倍精度値として格納されます。(par_id3163710.10)

As opposed to the DateSerial or the DateValue function, where serial date values result in days relative to a fixed date, you can calculate with the values that are returned by the TimeValue function, but you cannot evaluate them.
DateSerial や DateValue 関数では、日付データをシリアル値に変換する際に、固定設定された基準日からの経過日数として換算していますが、TimeValue 関数で返される値は、時刻間の計算には使えるものの、そのまま直接的な評価が行えるものではありません。(par_id3151117.11)

In the TimeSerial function, you can pass individual parameters (hour, minute, second) as separate numeric expressions. For the TimeValue function, however, you can pass a string as a parameter containing the time.
TimeSerial 関数の場合、関数に渡すパラメータ (時、分、秒) は、それぞれ個別の数値表式として指定することができます。これに対して TimeValue 関数では、時刻データを 1 つの文字列の形で渡します。(par_id3147426.12)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err13 : linkinfo)

13 Type mismatch
13 型が一致しません (par_id3155593.49)

(/embed text/sbasic/shared/00000003.xhp#err13)

Example:
例:(hd_id3145271.13)

Sub ExampleTimerValue
Sub ExampleTimerValue(par_id3152597.30)

Dim daDT as Date
Dim daDT as Date(par_id3147348.31)

Dim a1, b1, c1, a2, b2, c2 as String
Dim a1, b1, c1, a2, b2, c2 as String(par_id3148576.32)

a1 = "start time"
a1 = "start time"(par_id3149378.33)

b1 = "end time"
b1 = "end time"(par_id3145800.34)

c1 = "total time"
c1 = "total time"(par_id3151074.35)

a2 = "8:34"
a2 = "8:34"(par_id3154492.37)

b2 = "18:12"
b2 = "18:12"(par_id3155602.38)

daDT = TimeValue(b2) - TimeValue(a2)
daDT = TimeValue(b2) - TimeValue(a2)(par_id3150715.39)

c2 = a1 & ": " & a2 & chr(13)
c2 = a1 & ":" & a2 & chr(13)(par_id3153838.40)

c2 = c2 & b1 & ": " & b2 & chr(13)
c2 = c2 & b1 & ":" & b2 & chr(13)(par_id3150749.41)

c2 = c2 & c1 & ": " & trim(Str(Hour(daDT))) & ":" & trim(Str(Minute(daDT))) & ":" & trim(Str(Second(daDT)))
c2 = c2 & c1 & ":" & trim(Str(Hour(daDT))) & ":"& trim(Str(Minute(daDT))) & ":"& trim(Str(Second(daDT)))(par_id3154755.42)

Msgbox c2
Msgbox c2(par_id3153714.43)

end sub
end sub(par_id3155767.44)


< Prev / Next >